package com.jinlia.show.modules.system.config;

import com.jinlia.show.modules.base.system.service.OrderMapperService;
import com.jinlia.show.modules.base.utils.OrderNumGenerator;
import com.jinlia.show.modules.base.utils.PayOrderNumGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

import java.nio.charset.StandardCharsets;

@Component
public class BeanConfig {
    @Autowired
    OrderMapperService orderMapperService;
    @Bean
    public PayOrderNumGenerator payOrderNumGenerator() {
        PayOrderNumGenerator payOrderNumGenerator = new PayOrderNumGenerator();
        return payOrderNumGenerator;
    }
    @Bean(name = "dadaRestTemplate")
    public RestTemplate dadaRestTemplate() {
        RestTemplate dadaRestTemplate = new RestTemplate();
        dadaRestTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
        return dadaRestTemplate;
    }

    @Bean(name = "wxRestTemplate")
    public RestTemplate wxRestTemplate() {
        RestTemplate wxRestTemplate = new RestTemplate();
        wxRestTemplate.getMessageConverters().set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8));
        return wxRestTemplate;
    }
    @Bean
    public OrderNumGenerator orderNumGenerator() {
        OrderNumGenerator orderNumGenerator = new OrderNumGenerator(orderMapperService);
        return orderNumGenerator;
    }
}
